/*
Navicat SQL Server Data Transfer

Source Server         : LOCALHOST
Source Server Version : 110000
Source Host           : .:1433
Source Database       : AAACHAM2
Source Schema         : dbo

Target Server Type    : SQL Server
Target Server Version : 110000
File Encoding         : 65001

Date: 2014-04-22 23:00:23
*/


-- ----------------------------
-- Table structure for tb0000
-- ----------------------------
DROP TABLE [dbo].[tb0000]
GO
CREATE TABLE [dbo].[tb0000] (
[DefDivisionID] varchar(20) NULL ,
[DefTranMonth] int NULL ,
[DefTranYear] int NULL ,
[DefLoginDate] datetime NULL ,
[ScheduleDays] int NULL ,
[StartHour] int NULL DEFAULT ((8)) ,
[StartMinute] int NULL DEFAULT ((0)) ,
[EndHour] int NULL DEFAULT ((17)) ,
[EndMinute] int NULL DEFAULT ((0)) ,
[WareHouseID] varchar(20) NULL ,
[CurrencyID] varchar(20) NULL ,
[CashAccountID] varchar(20) NULL ,
[ReceivedAccountID] varchar(20) NULL ,
[PayableAccountID] varchar(20) NULL ,
[TurnOverAccountID] varchar(20) NULL ,
[PrimeCostAccountID] varchar(20) NULL ,
[VATInAccountID] varchar(20) NULL ,
[VATOutAccountID] varchar(20) NULL ,
[DifferenceAccountID] varchar(20) NULL ,
[LossExchangeAccID] varchar(20) NOT NULL DEFAULT ((635)) ,
[InterestExchangeAccID] varchar(20) NOT NULL DEFAULT ((515)) ,
[VATGroupID] varchar(20) NULL ,
[IsNegativeStock] tinyint NOT NULL DEFAULT ((0)) ,
[PaymentTermID] varchar(20) NULL ,
[IsDiscount] tinyint NOT NULL DEFAULT ((0)) ,
[IsAsoftM] tinyint NOT NULL DEFAULT ((0)) ,
[IsAsoftHRM] tinyint NOT NULL DEFAULT ((0)) ,
[IsAsoftOP] tinyint NOT NULL DEFAULT ((0)) ,
[PreCostAccountID] varchar(20) NULL ,
[IsCommission] tinyint NULL ,
[CommissionAccountID] varchar(20) NULL ,
[IsNegativeCash] tinyint NULL ,
[IsLockSalePrice] tinyint NULL ,
[IsAutoSourceNo] tinyint NOT NULL DEFAULT ((0)) ,
[IsTestSalePrice] tinyint NULL ,
[IsConsecutiveExchange] tinyint NOT NULL DEFAULT ((0)) ,
[StockAccountID] varchar(20) NULL ,
[PurchaseAccountID] varchar(20) NULL ,
[UnitID] varchar(20) NULL ,
[InventoryTypeID] varchar(20) NULL ,
[IsStocked] tinyint NULL ,
[IsSource] tinyint NULL ,
[IsLimitDate] tinyint NULL ,
[MethodID] tinyint NULL ,
[MessageQuantityAF3016] tinyint NULL ,
[MessageQuantityAF3013] tinyint NULL ,
[MessageQuantityAF4016] tinyint NULL ,
[MessageQuantityAF4017] tinyint NULL ,
[MessageUnitPriceAF3013] tinyint NULL ,
[MessageUnitPriceAF3016] tinyint NULL ,
[MessageUnitPriceAF4016] tinyint NULL ,
[MessageUnitPriceAF4017] tinyint NULL ,
[ObjectNameConstraint] tinyint NULL DEFAULT ((0)) ,
[TradeNameConstraint] tinyint NULL DEFAULT ((0)) ,
[VATNoConstraint] tinyint NULL DEFAULT ((0)) ,
[AddressConstraint] tinyint NULL DEFAULT ((0)) ,
[TelConstraint] tinyint NULL DEFAULT ((0)) ,
[MobileConstraint] tinyint NULL DEFAULT ((0)) ,
[FaxConstraint] tinyint NULL DEFAULT ((0)) ,
[EmailConstraint] tinyint NULL DEFAULT ((0)) ,
[WebsiteConstraint] tinyint NULL DEFAULT ((0)) ,
[ContactorConstraint] tinyint NULL DEFAULT ((0)) ,
[ObjectNameAllowNull] tinyint NULL DEFAULT ((0)) ,
[TradeNameAllowNull] tinyint NULL DEFAULT ((0)) ,
[VATNoAllowNull] tinyint NULL DEFAULT ((0)) ,
[AddressAllowNull] tinyint NULL DEFAULT ((0)) ,
[TelAllowNull] tinyint NULL DEFAULT ((0)) ,
[MobileAllowNull] tinyint NULL DEFAULT ((0)) ,
[FaxAllowNull] tinyint NULL DEFAULT ((0)) ,
[EmailAllowNull] tinyint NULL DEFAULT ((0)) ,
[WebsiteAllowNull] tinyint NULL DEFAULT ((0)) ,
[ContactorAllowNull] tinyint NULL DEFAULT ((0)) ,
[AutoCompactString] tinyint NULL DEFAULT ((0)) ,
[PhoneIsNumber] tinyint NULL DEFAULT ((0)) ,
[VATImGroupID] varchar(20) NULL ,
[VATImPercent] money NULL ,
[Approve] tinyint NULL ,
[Notes01Caption] nvarchar(100) NULL ,
[Notes02Caption] nvarchar(100) NULL ,
[Notes03Caption] nvarchar(100) NULL ,
[SpecificationCaption] nvarchar(100) NULL ,
[Notes01Type] int NULL ,
[Notes02Type] int NULL ,
[Notes03Type] int NULL ,
[SpecificationType] int NULL ,
[Notes01Last] nvarchar(100) NULL ,
[Notes02Last] nvarchar(100) NULL ,
[Notes03Last] nvarchar(100) NULL ,
[SpecificationLast] nvarchar(100) NULL ,
[Varchar01Caption] nvarchar(100) NULL ,
[Varchar02Caption] nvarchar(100) NULL ,
[Varchar03Caption] nvarchar(100) NULL ,
[Varchar04Caption] nvarchar(100) NULL ,
[Varchar05Caption] nvarchar(100) NULL ,
[Varchar01Type] int NULL ,
[Varchar02Type] int NULL ,
[Varchar03Type] int NULL ,
[Varchar04Type] int NULL ,
[Varchar05Type] int NULL ,
[Varchar01Last] nvarchar(100) NULL ,
[Varchar02Last] nvarchar(100) NULL ,
[Varchar03Last] nvarchar(100) NULL ,
[Varchar04Last] nvarchar(100) NULL ,
[Varchar05Last] nvarchar(100) NULL ,
[Ana01Type] int NULL ,
[Ana02Type] int NULL ,
[Ana03Type] int NULL ,
[Ana04Type] int NULL ,
[Ana05Type] int NULL ,
[Ana06Type] int NULL ,
[Ana07Type] int NULL ,
[Ana08Type] int NULL ,
[Ana09Type] int NULL ,
[Ana10Type] int NULL ,
[Ana11Type] int NULL ,
[Ana12Type] int NULL ,
[Ana13Type] int NULL ,
[Ana14Type] int NULL ,
[Ana15Type] int NULL ,
[Ana01Last] nvarchar(100) NULL ,
[Ana02Last] nvarchar(100) NULL ,
[Ana03Last] nvarchar(100) NULL ,
[Ana04Last] nvarchar(100) NULL ,
[Ana05Last] nvarchar(100) NULL ,
[Ana06Last] nvarchar(100) NULL ,
[Ana07Last] nvarchar(100) NULL ,
[Ana08Last] nvarchar(100) NULL ,
[Ana09Last] nvarchar(100) NULL ,
[Ana10Last] nvarchar(100) NULL ,
[Ana11Last] nvarchar(100) NULL ,
[Ana12Last] nvarchar(100) NULL ,
[Ana13Last] nvarchar(100) NULL ,
[Ana14Last] nvarchar(100) NULL ,
[Ana15Last] nvarchar(100) NULL ,
[IsUpdateInventoryName] int NULL ,
[PreCostAccountID2] varchar(20) NULL ,
[UsePriceSheet] int NULL ,
[Report15or48] nvarchar(200) NULL ,
[IsOverDue] int NULL ,
[IsOverDueSave] int NULL ,
[IsOverDueShow] int NULL ,
[IsPromotion] int NULL ,
[IsAllInventoryID] int NULL ,
[IsAllObjectID] int NULL ,
[IsAllAccountID] int NULL ,
[IsAllVoucherTypeID] int NULL ,
[IsAllBankAccountID] int NULL,
QuantityDecimals INT NULL,
ConvertedDecimals INT NULL,
UnitCostDecimals INT NULL
)


GO

-- ----------------------------
-- Triggers structure for table tb0000
-- ----------------------------

--DROP TRIGGER [dbo].[AY0000]
GO
CREATE TRIGGER [dbo].[AY0000]
ON [dbo].[tb0000]
AFTER INSERT, UPDATE
AS

Update tb0137 
set Disabled  = (Case When Ins.IsAsoftOP = 1 then 0 else 1 End)
From tb0137 , Inserted Ins
Where tb0137.Code in ('PO', 'SO')

GO


-- ----------------------------
-- Records of tb0000
-- ----------------------------
INSERT INTO [dbo].[tb0000] ([DefDivisionID], [DefTranMonth], [DefTranYear], [DefLoginDate], [ScheduleDays], [StartHour], [StartMinute], [EndHour], [EndMinute], [WareHouseID], [CurrencyID], [CashAccountID], [ReceivedAccountID], [PayableAccountID], [TurnOverAccountID], [PrimeCostAccountID], [VATInAccountID], [VATOutAccountID], [DifferenceAccountID], [LossExchangeAccID], [InterestExchangeAccID], [VATGroupID], [IsNegativeStock], [PaymentTermID], [IsDiscount], [IsAsoftM], [IsAsoftHRM], [IsAsoftOP], [PreCostAccountID], [IsCommission], [CommissionAccountID], [IsNegativeCash], [IsLockSalePrice], [IsAutoSourceNo], [IsTestSalePrice], [IsConsecutiveExchange], [StockAccountID], [PurchaseAccountID], [UnitID], [InventoryTypeID], [IsStocked], [IsSource], [IsLimitDate], [MethodID], [MessageQuantityAF3016], [MessageQuantityAF3013], [MessageQuantityAF4016], [MessageQuantityAF4017], [MessageUnitPriceAF3013], [MessageUnitPriceAF3016], [MessageUnitPriceAF4016], [MessageUnitPriceAF4017], [ObjectNameConstraint], [TradeNameConstraint], [VATNoConstraint], [AddressConstraint], [TelConstraint], [MobileConstraint], [FaxConstraint], [EmailConstraint], [WebsiteConstraint], [ContactorConstraint], [ObjectNameAllowNull], [TradeNameAllowNull], [VATNoAllowNull], [AddressAllowNull], [TelAllowNull], [MobileAllowNull], [FaxAllowNull], [EmailAllowNull], [WebsiteAllowNull], [ContactorAllowNull], [AutoCompactString], [PhoneIsNumber], [VATImGroupID], [VATImPercent], [Approve], [Notes01Caption], [Notes02Caption], [Notes03Caption], [SpecificationCaption], [Notes01Type], [Notes02Type], [Notes03Type], [SpecificationType], [Notes01Last], [Notes02Last], [Notes03Last], [SpecificationLast], [Varchar01Caption], [Varchar02Caption], [Varchar03Caption], [Varchar04Caption], [Varchar05Caption], [Varchar01Type], [Varchar02Type], [Varchar03Type], [Varchar04Type], [Varchar05Type], [Varchar01Last], [Varchar02Last], [Varchar03Last], [Varchar04Last], [Varchar05Last], [Ana01Type], [Ana02Type], [Ana03Type], [Ana04Type], [Ana05Type], [Ana06Type], [Ana07Type], [Ana08Type], [Ana09Type], [Ana10Type], [Ana11Type], [Ana12Type], [Ana13Type], [Ana14Type], [Ana15Type], [Ana01Last], [Ana02Last], [Ana03Last], [Ana04Last], [Ana05Last], [Ana06Last], [Ana07Last], [Ana08Last], [Ana09Last], [Ana10Last], [Ana11Last], [Ana12Last], [Ana13Last], [Ana14Last], [Ana15Last], [IsUpdateInventoryName], [PreCostAccountID2], [UsePriceSheet], [Report15or48], [IsOverDue], [IsOverDueSave], [IsOverDueShow], [IsPromotion], [IsAllInventoryID], [IsAllObjectID], [IsAllAccountID], [IsAllVoucherTypeID], [IsAllBankAccountID]) VALUES (N'HPCNB2013', N'1', N'2014', null, N'4', N'8', N'0', N'17', N'0', null, N'VND', N'1111', N'1311', N'3311', N'5111', N'6321', N'13311', N'33311', N'4131', N'', N'', N'', N'1', N'', N'0', N'1', N'1', N'1', N'1422', N'0', N'', N'0', N'0', N'0', N'0', N'0', N'', N'', N'CA', N'HH', N'1', N'0', N'0', N'4', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'1', N'1', null, null, N'0', N'Ghi chuù 1', N'Ghi chuù 2', N'Ghi chuù 3', N'Ñaëc tính kyõ thuaät', null, null, null, null, null, null, null, null, N'Tham soá 1', N'Tham soá 2', N'Tham soá 3', N'Tham soá 4', N'Tham soá 5', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, N'0', N'', N'0', N'', N'0', N'1', N'1', N'1', N'1', N'1', N'1', N'1', N'1')
GO
GO